package com.zhentao.controller;

import com.zhentao.domain.SysPreferentialExplain;
import com.zhentao.domain.SysUser;
import com.zhentao.domain.infoVo.UserInfoSCVo;
import com.zhentao.domain.infoVo.UserInfoYHJVo;
import com.zhentao.domain.vo.Result;
import com.zhentao.service.SysPreferentialExplainService;
import com.zhentao.service.SysUserService;

import com.zhentao.service.impl.SysPreferentialExplainServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Tag(name = "用户管理")
public class UserController {
    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private SysPreferentialExplainService sysPreferentialExplainService;
//   查询用户信息
    @GetMapping("/getUser")
    public Result getUser() {
        //    @RequestHeader("Authorization")String token
        SysUser byId = sysUserService.getUserInfo();
            return Result.build(byId, 200, "查询成功");
    }
    //    修改用户信息
    @PostMapping("/updateUser")
    @Operation(summary = "修改用户信息")
    public Result updateUser(@RequestBody SysUser sysUser){
        int i = sysUserService.updateUserInfo(sysUser);
        return Result.build(i, 200, "修改成功");
    }
    //查询收藏站点
    @GetMapping("/getUserSc")
    @Operation(summary = "查询收藏站点")
    public Result getUserSc(@RequestHeader("Authorization")String token){ //    @RequestHeader("Authorization")String token
        UserInfoSCVo userInfoSc = sysUserService.getUserInfoSc(token);
        return Result.build(userInfoSc, 200, "查询成功");
    }
//    查询用户优惠卷
    @GetMapping("/getUserYhj")
    @Operation(summary = "查询用户优惠卷")
    public Result getUserYhj(@RequestHeader("Authorization")String token){ //    @RequestHeader("Authorization")String token
        List<UserInfoYHJVo> userInfoYhj = sysUserService.getUserInfoYhj(token);
        return Result.build(userInfoYhj, 200, "查询成功");
    }
    //    查询用户优惠卷不可用
    @GetMapping("/getNotUserYhj")
    @Operation(summary = "查询不可用的优惠卷")
    public Result getNotUserYhj(@RequestHeader("Authorization")String token){ //    @RequestHeader("Authorization")String token
        List<UserInfoYHJVo> userInfoYhj = sysUserService.getNotUserInfoYhj(token);
        return Result.build(userInfoYhj, 200, "查询成功");
    }
//    查看优惠卷说明信息
//@GetMapping("/getYhjExplain")
//   public Result getYhjExplain(){
//    List<SysPreferentialExplain> all = sysPreferentialExplainService.getAll();
//    return Result.build(all, 200, "查询成功");
//}
//    查看优惠卷说明信息
    @GetMapping("/getYhjExplain")
    @Operation(summary = "查看优惠卷说明信息")
    public Result getYhjExplain(){
        List<SysPreferentialExplain> all = sysPreferentialExplainService.getAll();
        return Result.build(all, 200, "查询成功");
    }
}
